#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

ll qmi(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        res = res * a % mod;
        b >>= 1;
        a = a * a % mod;
    }
    return res;
}

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int x, y, k;
        cin >> x >> y >> k;
        int a = (a + (k - 1)) / k;
        int b = (b + (k - 1)) / k ;
        if(a > b)
        {
            cout << a * 2 - 1 << endl;
        }
        else{
            cout << b * 2 << endl;
        }
    }
    return 0;
}